<template>
  <div class="app-container">
    <el-card>
      <el-page-header @back="goBack">
        <template #content>
          <div class="flex items-center">
            <div>
              生产单分配列表明细
              <el-tag>{{ form.produceNo }}</el-tag>
            </div>
          </div>
        </template>
        <template #extra>
          <div class="flex items-center" v-if="!route.query.info">
            <el-button type="primary" @click="submitForm">审 核</el-button>
          </div>
        </template>
      </el-page-header>
    </el-card>
    <el-card style="margin-top: 10px">
      <el-collapse v-model="activeNames">
        <el-collapse-item disabled title="基本信息" name="1">
          <template #title>
            <el-icon style="color: #4479f6">
              <Position />
            </el-icon>
            <span class="title">基本信息</span>
          </template>
          <div>
            <el-form
              :model="form"
              :rules="rules"
              :disabled="flag"
              ref="userRef"
              label-width="120px"
            >
              <el-row :gutter="20">
                <el-col :span="8">
                  <el-form-item label="下单日期" prop="submitDate">
                    <el-date-picker
                      style="width: 100%"
                      disabled
                      v-model="form.submitDate"
                      value-format="YYYY-MM-DD "
                      type="date"
                      placeholder="请选择日期"
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="新/旧版" prop="isNew">
                    <el-select
                      style="width: 100%"
                      disabled
                      v-model="form.isNew"
                      placeholder="请选择"
                    >
                      <el-option
                        v-for="item in ems_produce_is_new"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      />
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="出版编码" prop="pubNo">
                    <el-input
                      v-model="form.pubNo"
                      disabled
                      :validate-event="false"
                      placeholder="请输入出版编码"
                      maxlength="20"
                    />
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="20">
                <el-col :span="8">
                  <el-form-item label="车间" prop="workshopId">
                    <el-select
                      style="width: 100%"
                      disabled
                      v-model="form.workshopId"
                      placeholder="请选择车间"
                    >
                      <el-option
                        v-for="item in ems_workshop"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      />
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="交货日期" prop="deliverDate">
                    <el-date-picker
                      disabled
                      style="width: 100%"
                      v-model="form.deliverDate"
                      value-format="YYYY-MM-DD "
                      type="date"
                      placeholder="请选择日期"
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="文件日期" prop="fileDate">
                    <el-date-picker
                      disabled
                      style="width: 100%"
                      v-model="form.fileDate"
                      value-format="YYYY-MM-DD "
                      type="date"
                      placeholder="请选择日期"
                    />
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="20" v-if="form.type == 1">
                <el-col :span="8">
                  <el-form-item label="加急交货日期" prop="urgentDate">
                    <el-date-picker
                      style="width: 100%"
                      v-model="form.urgentDate"
                      format="YYYY-MM-DD HH:mm:ss"
                      disabled
                      date-format="MMM DD, YYYY"
                      time-format="HH:mm"
                      type="datetime"
                      placeholder="请选择时间"
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="打包要求" prop="packageRequire">
                    <el-select
                      style="width: 100%"
                      disabled
                      v-model="form.packageRequire"
                      placeholder="请选择"
                    >
                      <el-option
                        v-for="item in ems_produce_package_require"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      />
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
              <div v-else>
                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-form-item label="定价" prop="fixPrice">
                      <el-input
                        disabled
                        v-model="form.fixPrice"
                        type="number"
                        placeholder="请输入定价"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="打包方式" prop="packWay">
                      <el-input
                        disabled
                        v-model="form.packWay"
                        placeholder="请输入打包方式"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="包内数量" prop="packInNum">
                      <el-input
                        v-model="form.packInNum"
                        type="number"
                        disabled
                        placeholder="请输入包内数量"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-form-item label="打包要求" prop="packageRequire">
                      <el-select
                        style="width: 100%"
                        v-model="form.packageRequire"
                        placeholder="请选择"
                        disabled
                      >
                        <el-option
                          v-for="item in ems_produce_package_require"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value"
                        />
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="印刷次数" prop="printNum">
                      <el-input
                        v-model="form.printNum"
                        disabled
                        type="number"
                        placeholder="自动带出"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="印次" prop="printNo">
                      <el-input
                        disabled
                        v-model="form.printNo"
                        placeholder="请输入印次"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-form-item label="产品名称" prop="productName">
                      <el-input
                        v-model="form.productName"
                        disabled
                        placeholder="自动带出"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="出版社" prop="publishingHouse">
                      <el-input
                        disabled
                        v-model="form.publishingHouse"
                        placeholder="自动带出"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="书号" prop="bookNo">
                      <el-input
                        disabled
                        v-model="form.bookNo"
                        placeholder="自动带出"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
              </div>
              <!-- <el-row :gutter="20">
                                <el-col :span="24">
                                    <el-form-item label="分配机台">
                                        <el-tag
                                            style="margin-right: 10px"
                                            v-for="(item, index) in machineNameList"
                                            :key="index"
                                            >{{ item }}</el-tag
                                        >
                                    </el-form-item>
                                </el-col>
                            </el-row> -->

              <!-- <el-row :gutter="20">
                                <el-col :span="24">
                                    <el-form-item label="分配车间">
                                        <el-tag
                                            style="margin-right: 10px"
                                            v-for="(item, index) in workshopNameList"
                                            :key="index"
                                            >{{ item }}</el-tag
                                        >
                                    </el-form-item>
                                </el-col>
                            </el-row> -->
              <el-row :gutter="20">
                <el-col :span="24">
                  <el-form-item label="备注">
                    <el-input
                      v-model="form.remark"
                      type="textarea"
                      placeholder="请输入内容"
                    ></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
          </div>
        </el-collapse-item>
        <div v-if="form.type == 1">
          <el-collapse-item disabled title="产品信息" name="2">
            <template #title>
              <el-icon style="color: #4479f6">
                <Position />
              </el-icon>
              <span class="title">产品信息</span>
            </template>
            <div class="order-form">
              <el-table :data="data.produceProductList" border>
                <el-table-column
                  label="序号"
                  width="60"
                  type="index"
                  align="center"
                />
                <el-table-column
                  label="产品序列号"
                  v-if="route.query?.id"
                  min-width="120"
                  prop="productNo"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="订单数量"
                  width="120"
                  prop="produceCount"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="书刊名称"
                  min-width="280"
                  prop="bookName"
                  align="center"
                ></el-table-column>
                <!-- <el-table-column label="是否做版" prop="newPast" min-width="160" align="center">
                                    <template #default="scope">
                                        <dict-tag :options="ems_produce_new_past" :value="scope.row.newPast" />
                                    </template>
                                </el-table-column> -->
                <el-table-column
                  label="产品品种"
                  prop="breedType"
                  min-width="160"
                  align="center"
                >
                  <!-- <template #default="scope">
                                        <dict-tag
                                            :options="ems_order_breed_type"
                                            :value="scope.row.breedType"
                                        />
                                    </template> -->
                </el-table-column>
                <el-table-column
                  label="清样编号"
                  min-width="120"
                  prop="sampleNo"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="文件号"
                  min-width="120"
                  prop="fileNo"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="书号"
                  min-width="120"
                  prop="bookNo"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="定价"
                  min-width="100"
                  prop="fixPrice"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="组成"
                  min-width="140"
                  prop="composition"
                  align="center"
                >
                  <!-- <template #default="scope">
                                        <dict-tag
                                            :options="ems_order_make_up_fm"
                                            :value="scope.row.composition"
                                        />
                                    </template> -->
                </el-table-column>
                <el-table-column
                  label="印色"
                  min-width="100"
                  prop="printColor"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="ems_order_print_color"
                      :value="scope.row.printColor"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="颜色"
                  width="120"
                  prop="color"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="ems_produce_color"
                      :value="scope.row.color"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="用纸尺寸"
                  prop="paperSize"
                  width="120"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="ems_produce_paper_size"
                      :value="scope.row.paperSize"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="纸型"
                  width="120"
                  prop="paperType"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="mes_paper_type"
                      :value="scope.row.paperType"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="纸张编码"
                  width="120"
                  prop="paperNo"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="覆膜"
                  width="100"
                  prop="coverFilm"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="ems_produce_cover_film"
                      :value="scope.row.coverFilm"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="喷码"
                  width="80"
                  prop="marking"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="ems_produce_marking"
                      :value="scope.row.marking"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="连版数量"
                  width="100"
                  prop="lianbanCount"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="内文承印厂"
                  width="120"
                  prop="textPrinter"
                  align="center"
                ></el-table-column>
                <!-- <el-table-column
                                    label="客户名称"
                                    width="120"
                                    prop="customerName"
                                    align="center"
                                ></el-table-column> -->
                <el-table-column
                  label="科目"
                  min-width="120"
                  prop="subjectType"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="ems_workshop_subject_type"
                      :value="scope.row.subjectType"
                    />
                  </template>
                </el-table-column>
              </el-table>
            </div>
            <h4>备注</h4>
            <el-input
              v-model="form.remark1"
              disabled
              type="textarea"
              placeholder="请输入内容"
            ></el-input>
          </el-collapse-item>
          <el-collapse-item disabled title="纸张信息" name="3">
            <template #title>
              <el-icon style="color: #4479f6">
                <Position />
              </el-icon>
              <span class="title">纸张信息</span>
            </template>
            <div class="order-form">
              <el-table
                :data="data.producePaperList"
                ref="producePaperListRef"
                border
              >
                <el-table-column
                  label="序号"
                  width="60"
                  type="index"
                  align="center"
                />
                <el-table-column
                  label="纸张序列号"
                  min-width="120"
                  prop="paperProduceNo"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="纸张编码"
                  min-width="120"
                  prop="paperNo"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="纸张类型"
                  prop="type"
                  width="120"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="mes_paper_material"
                      :value="scope.row.type"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="纸型"
                  min-width="120"
                  prop="paperType"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="mes_paper_type"
                      :value="scope.row.paperType"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="定量"
                  min-width="90"
                  prop="weight"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="规格"
                  min-width="120"
                  prop="specifications"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="mes_paper_specs"
                      :value="scope.row.specifications"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="幅宽(mm)"
                  min-width="100"
                  prop="length"
                  align="center"
                ></el-table-column>
                <!-- <el-table-column
                                    label="宽度(mm)"
                                    min-width="100"
                                    prop="width"
                                    align="center"
                                ></el-table-column> -->
                <el-table-column
                  label="单位"
                  min-width="80"
                  prop="unit"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="mes_paper_unit"
                      :value="scope.row.unit"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="库存数量"
                  min-width="100"
                  prop="amount"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="数量"
                  min-width="90"
                  prop="reamAmount"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="裁切尺寸"
                  width="120"
                  prop="size"
                  align="center"
                ></el-table-column>
                <!-- <el-table-column
                                    label="加权单价"
                                    min-width="120"
                                    prop="unitPrice"
                                    align="center"
                                ></el-table-column>
                                <el-table-column
                                    label="金额"
                                    width="120"
                                    prop="price"
                                    align="center"
                                ></el-table-column> -->
              </el-table>
            </div>
            <h4>备注</h4>
            <el-input
              v-model="form.remark2"
              disabled
              type="textarea"
              placeholder="请输入内容"
            ></el-input>
          </el-collapse-item>
          <el-collapse-item disabled title="印刷管理" name="4">
            <template #title>
              <el-icon style="color: #4479f6">
                <Position />
              </el-icon>
              <span class="title">印刷管理</span>
            </template>
            <div class="order-form">
              <el-table
                :data="data.producePrintList"
                ref="producePrintListRef"
                border
              >
                <el-table-column
                  label="序号"
                  width="60"
                  type="index"
                  align="center"
                />
                <el-table-column
                  label="印刷序列号"
                  min-width="120"
                  prop="printProduceNo"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="组成"
                  min-width="160"
                  prop="composition"
                  align="center"
                >
                  <!-- <template #default="scope">
                                        <dict-tag
                                            :options="ems_order_make_up_fm"
                                            :value="scope.row.composition"
                                        />
                                    </template> -->
                </el-table-column>
                <el-table-column
                  label="纸型"
                  width="120"
                  prop="paperType"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="mes_paper_type"
                      :value="scope.row.paperType"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="定量"
                  width="80"
                  prop="weight"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="印数"
                  width="100"
                  prop="pri
                                ntAmount"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="用纸令数"
                  width="100"
                  prop="reamAmount"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="损耗系数"
                  width="110"
                  prop="lossCoefficient"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="损耗令数"
                  width="120"
                  prop="lossReam"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="用纸总令数"
                  width="120"
                  prop="totalReamAmount"
                  align="center"
                >
                </el-table-column>
                <el-table-column
                  label="另行加放"
                  width="120"
                  prop="lxjf"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="印色"
                  width="100"
                  prop="printColour"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="ems_order_print_color"
                      :value="scope.row.printColour"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="印色方式"
                  prop="printColourType"
                  width="120"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="ems_produce_print_colour_type"
                      :value="scope.row.printColourType"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="版材数量"
                  width="100"
                  prop="sheetAmount"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="版材尺寸"
                  prop="sheetSize"
                  width="120"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="ems_machine_info_size"
                      :value="scope.row.sheetSize"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="活页烤版"
                  prop="hykb"
                  width="120"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="ems_produce_hykb"
                      :value="scope.row.hykb"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="印刷联版图号"
                  width="120"
                  prop="yslbth"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="幅宽"
                  width="100"
                  prop="clothWidth"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="品牌"
                  width="120"
                  prop="brand"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="mes_paper_brand"
                      :value="scope.row.brand"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="工艺"
                  min-width="160"
                  prop="technologyId"
                  align="center"
                >
                  <template #default="scope">
                    <el-select
                      clearable
                      style="width: 100%"
                      disabled
                      v-model="scope.row.technologyId"
                      placeholder="请选择工艺"
                    >
                      <el-option
                        v-for="item in technologyList"
                        :key="item.id"
                        :label="item.name"
                        :value="item.id"
                      />
                    </el-select>
                  </template>
                </el-table-column>
                <el-table-column
                  label="白纸裁切"
                  width="160"
                  prop="whitecuttingMachine"
                  align="center"
                >
                  <template #default="scope">
                    <el-button
                      link
                      :disabled="flag"
                      type="primary"
                      @click="
                        handlePrintWorkBranch(
                          scope.row,
                          scope.$index,
                          '5',
                          'whitecuttingMachine'
                        )
                      "
                    >
                      <div>
                        <div
                          v-for="item in scope.row.whitecuttingMachine?.split(
                            '/'
                          )"
                          :key="item"
                        >
                          {{ item }}
                        </div>
                      </div>
                      <!-- {{ scope.row.whitecuttingMachine }} -->
                    </el-button>
                  </template>
                </el-table-column>
                <el-table-column
                  label="印刷"
                  width="180"
                  prop="printMachine"
                  align="center"
                >
                  <template #default="scope">
                    <el-button
                      link
                      :disabled="flag"
                      type="primary"
                      @click="
                        handlePrintWorkBranch(
                          scope.row,
                          scope.$index,
                          '2',
                          'printMachine'
                        )
                      "
                    >
                      <div>
                        <div
                          v-for="item in scope.row.printMachine?.split('/')"
                          :key="item"
                        >
                          {{ item }}
                        </div>
                      </div>
                    </el-button>
                  </template>
                </el-table-column>
                <el-table-column
                  label="封面裁切"
                  width="160"
                  prop="covercuttingMachine"
                  align="center"
                >
                  <template #default="scope">
                    <el-button
                      link
                      type="primary"
                      :disabled="flag"
                      @click="
                        handlePrintWorkBranch(
                          scope.row,
                          scope.$index,
                          '6',
                          'covercuttingMachine'
                        )
                      "
                    >
                      <div>
                        <div
                          v-for="item in scope.row.covercuttingMachine?.split(
                            '/'
                          )"
                          :key="item"
                        >
                          {{ item }}
                        </div>
                      </div>
                      <!-- {{ scope.row.covercuttingMachine }} -->
                    </el-button>
                  </template>
                </el-table-column>
                <el-table-column
                  label="覆膜"
                  width="160"
                  prop="coveringMachine"
                  align="center"
                >
                  <template #default="scope">
                    <el-button
                      link
                      :disabled="flag"
                      type="primary"
                      @click="
                        handlePrintWorkBranch(
                          scope.row,
                          scope.$index,
                          '7',
                          'coveringMachine'
                        )
                      "
                    >
                      <div>
                        <div
                          v-for="item in scope.row.coveringMachine?.split('/')"
                          :key="item"
                        >
                          {{ item }}
                        </div>
                      </div>
                      <!-- {{ scope.row.coveringMachine }} -->
                    </el-button>
                  </template>
                </el-table-column>
                <el-table-column
                  label="折页"
                  width="160"
                  prop="foldMachine"
                  align="center"
                >
                  <template #default="scope">
                    <el-button
                      link
                      :disabled="flag"
                      type="primary"
                      @click="
                        handlePrintWorkBranch(
                          scope.row,
                          scope.$index,
                          '4',
                          'foldMachine'
                        )
                      "
                    >
                      <div>
                        <div
                          v-for="item in scope.row.foldMachine?.split('/')"
                          :key="item"
                        >
                          {{ item }}
                        </div>
                      </div>
                      <!-- {{ scope.row.foldMachine }} -->
                    </el-button>
                  </template>
                </el-table-column>
                <el-table-column
                  label="装订"
                  min-width="200"
                  prop="bindingMachine"
                  align="center"
                >
                  <template #default="scope">
                    <el-button
                      link
                      :disabled="flag"
                      type="primary"
                      @click="
                        handlePrintWorkBranch(
                          scope.row,
                          scope.$index,
                          '3',
                          'bindingMachine'
                        )
                      "
                    >
                      <div>
                        <div
                          v-for="item in scope.row.bindingMachine?.split('/')"
                          :key="item"
                        >
                          {{ item }}
                        </div>
                      </div>
                      <!-- {{ scope.row.bindingMachine }} -->
                    </el-button>
                  </template>
                </el-table-column>
                <!-- <el-table-column label="分配车间" width="120" prop="workshopName" align="center">
                                </el-table-column> -->
                <!-- <el-table-column label="操作" v-if="!route.query.info" align="center" fixed="right"
                                    class-name="small-padding fixed-width">
                                    <template #default="scope">
                                        <el-button link type="primary"
                                            @click="handlePrintPoints(scope.row, scope.$index)">分配机台</el-button>
                                    </template>
                                </el-table-column> -->
              </el-table>
            </div>
            <h4>备注</h4>
            <el-input
              v-model="form.remark3"
              disabled
              type="textarea"
              placeholder="请输入内容"
            ></el-input>
          </el-collapse-item>
          <el-collapse-item disabled title="覆膜管理" name="5">
            <template #title>
              <el-icon style="color: #4479f6">
                <Position />
              </el-icon>
              <span class="title">覆膜管理</span>
            </template>
            <div class="order-form">
              <el-table
                :data="data.produceCoveringList"
                ref="produceCoveringListRef"
                border
              >
                <el-table-column
                  label="序号"
                  width="60"
                  type="index"
                  align="center"
                />
                <el-table-column
                  label="覆膜序列号"
                  min-width="120"
                  prop="produceCoveringNo"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="组成"
                  min-width="160"
                  prop="composition"
                  align="center"
                >
                  <!-- <template #default="scope">
                                        <dict-tag
                                            :options="ems_order_make_up_fm"
                                            :value="scope.row.composition"
                                        />
                                    </template> -->
                </el-table-column>
                <el-table-column
                  label="覆膜"
                  min-width="160"
                  prop="covering"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="ems_produce_cover_film"
                      :value="scope.row.covering"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="用膜"
                  width="120"
                  prop="useCovering"
                  align="center"
                ></el-table-column>

                <el-table-column
                  label="定量"
                  width="120"
                  prop="weight"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="纸型"
                  width="120"
                  prop="paperType"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="mes_paper_type"
                      :value="scope.row.paperType"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="规格型号"
                  min-width="120"
                  prop="specification"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="mes_paper_specs"
                      :value="scope.row.specification"
                    />
                  </template>
                </el-table-column>
                <!-- <el-table-column
                                    label="覆膜尺寸"
                                    width="120"
                                    prop="coveringSize"
                                    align="center"
                                ></el-table-column>
                                <el-table-column
                                    label="成品尺寸"
                                    width="120"
                                    prop="finishSize"
                                    align="center"
                                >
                                    <template #default="scope">
                                        <dict-tag
                                            :options="ems_produce_finish_size"
                                            :value="scope.row.finishSize"
                                        />
                                    </template>
                                </el-table-column> -->
                <el-table-column
                  label="令数"
                  width="120"
                  prop="ream"
                  align="center"
                ></el-table-column>
              </el-table>
            </div>
            <h4>备注</h4>
            <el-input
              v-model="form.remark4"
              disabled
              type="textarea"
              placeholder="请输入内容"
            ></el-input>
          </el-collapse-item>
        </div>
        <div v-else>
          <el-collapse-item disabled title="产品信息" name="2">
            <template #title>
              <el-icon style="color: #4479f6">
                <Position />
              </el-icon>
              <span class="title">产品信息</span>
            </template>
            <div class="order-form">
              <el-table :data="data.produceProductList" border>
                <el-table-column
                  label="序号"
                  width="60"
                  type="index"
                  align="center"
                />
                <el-table-column
                  label="订单数量"
                  width="120"
                  prop="produceCount"
                  align="center"
                ></el-table-column>

                <el-table-column
                  label="品种"
                  prop="breedType"
                  min-width="160"
                  align="center"
                >
                  <!-- <template #default="scope">
                                        <dict-tag
                                            :options="ems_order_breed_type"
                                            :value="scope.row.breedType"
                                        />
                                    </template> -->
                </el-table-column>
                <el-table-column
                  label="装订方式"
                  min-width="160"
                  prop="bindingMode"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="ems_order_binding_mode"
                      :value="scope.row.bindingMode"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="开本数"
                  min-width="160"
                  prop="bookSize"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="ems_produce_book_size"
                      :value="scope.row.bookSize"
                    />
                  </template>
                </el-table-column>

                <el-table-column
                  label="详细信息"
                  min-width="200"
                  prop="detail"
                  align="center"
                >
                  <!-- <template #default="scope">
                                        <el-form-item>
                                            <el-input
                                                disabled
                                                v-model="scope.row.detail"
                                                type="textarea"
                                                placeholder="请输入详细信息"
                                            ></el-input>
                                        </el-form-item>
                                    </template> -->
                </el-table-column>
                <el-table-column
                  label="印色"
                  min-width="160"
                  prop="printColor"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="ems_order_print_color"
                      :value="scope.row.printColor"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="颜色"
                  width="120"
                  prop="color"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="ems_produce_color"
                      :value="scope.row.color"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="用纸尺寸"
                  prop="paperSize"
                  width="120"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="ems_produce_paper_size"
                      :value="scope.row.paperSize"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="纸型"
                  width="120"
                  prop="paperType"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="mes_paper_type"
                      :value="scope.row.paperType"
                    />
                  </template>
                </el-table-column>

                <el-table-column
                  label="纸张编码"
                  width="120"
                  prop="paperNo"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="版材尺寸"
                  min-width="160"
                  prop="sheetSize"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="ems_machine_info_size"
                      :value="scope.row.sheetSize"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="成品尺寸(mm)"
                  width="120"
                  prop="finishSize"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="ems_produce_finish_size"
                      :value="scope.row.finishSize"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="贴数信息"
                  width="120"
                  prop="piece"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="用版数量"
                  width="120"
                  prop="boardsCount"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="清样编号"
                  min-width="120"
                  prop="sampleNo"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="印张"
                  width="120"
                  prop="sheet"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="烤版"
                  width="100"
                  prop="kaoban"
                  align="center"
                >
                  <template #default="scope">
                    <el-form-item>
                      <el-select
                        disabled
                        style="width: 100%"
                        v-model="scope.row.kaoban"
                        placeholder="请选择烤版"
                      >
                        <el-option label="是" value="1" />
                        <el-option label="否" value="2" />
                      </el-select>
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column
                  label="产品序列号"
                  min-width="120"
                  prop="productNo"
                  align="center"
                ></el-table-column>
              </el-table>
            </div>
            <h4>备注</h4>
            <el-input
              v-model="form.remark1"
              disabled
              type="textarea"
              placeholder="请输入内容"
            ></el-input>
          </el-collapse-item>
          <el-collapse-item disabled title="纸张信息" name="3">
            <template #title>
              <el-icon style="color: #4479f6">
                <Position />
              </el-icon>
              <span class="title">纸张信息</span>
            </template>
            <div class="order-form">
              <el-table
                :data="data.producePaperList"
                ref="producePaperListRef"
                border
              >
                <el-table-column
                  label="序号"
                  width="60"
                  type="index"
                  align="center"
                />
                <el-table-column
                  label="纸张序列号"
                  min-width="120"
                  prop="paperProduceNo"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="纸张编码"
                  min-width="120"
                  prop="paperNo"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="纸张名称"
                  min-width="150"
                  prop="paperName"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="纸张类型"
                  prop="type"
                  width="120"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="mes_paper_material"
                      :value="scope.row.type"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="纸型"
                  min-width="120"
                  prop="paperType"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="mes_paper_type"
                      :value="scope.row.paperType"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="定量"
                  min-width="120"
                  prop="weight"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="规格"
                  min-width="120"
                  prop="specifications"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="mes_paper_specs"
                      :value="scope.row.specifications"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="幅宽(mm)"
                  min-width="120"
                  prop="length"
                  align="center"
                ></el-table-column>
                <!-- <el-table-column
                                    label="宽度(mm)"
                                    min-width="120"
                                    prop="width"
                                    align="center"
                                ></el-table-column> -->
                <el-table-column
                  label="单位"
                  min-width="120"
                  prop="unit"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="mes_paper_unit"
                      :value="scope.row.unit"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="库存数量"
                  min-width="120"
                  prop="amount"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="数量"
                  min-width="120"
                  prop="reamAmount"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="裁切尺寸"
                  width="120"
                  prop="size"
                  align="center"
                ></el-table-column>
                <!-- <el-table-column
                                    label="加权单价"
                                    min-width="120"
                                    prop="unitPrice"
                                    align="center"
                                ></el-table-column>
                                <el-table-column
                                    label="金额"
                                    width="120"
                                    prop="price"
                                    align="center"
                                ></el-table-column> -->
              </el-table>
            </div>
            <h4>备注</h4>
            <el-input
              v-model="form.remark2"
              disabled
              type="textarea"
              placeholder="请输入内容"
            ></el-input>
          </el-collapse-item>
          <el-collapse-item disabled title="不配套图书管理" name="4">
            <template #title>
              <el-icon style="color: #4479f6">
                <Position />
              </el-icon>
              <span class="title">不配套图书管理</span>
            </template>
            <div class="order-form">
              <div style="overflow-x: scroll">
                <table
                  border="2"
                  v-if="listBPT?.length > 0"
                  cellspacing="0"
                  cellpadding="6"
                >
                  <tr>
                    <td class="text" rowspan="2" style="width: 60px">
                      不配套图书
                    </td>
                    <td class="text" style="width: 300px">单号</td>
                    <td class="text" style="width: 100px">品种</td>
                    <td
                      class="text"
                      v-for="(item, index) in listBPT"
                      :key="index"
                      width="160"
                    >
                      {{ item.name }}
                    </td>
                  </tr>
                  <tr>
                    <td class="text">
                      <span disabled style="width: 300px">{{ orderNo }}</span>
                    </td>
                    <td class="text" style="width: 100px">数量</td>
                    <td
                      class="text"
                      disabled
                      v-for="(item, index) in listBPT"
                      :key="index"
                    >
                      <span style="width: 160px">{{ item.val }}</span>
                    </td>
                  </tr>
                </table>
              </div>
            </div>
          </el-collapse-item>
          <el-collapse-item disabled title=" 印刷管理" name="5">
            <template #title>
              <el-icon style="color: #4479f6">
                <Position />
              </el-icon>
              <span class="title">印刷管理</span>
            </template>
            <div class="order-form">
              <el-table
                :data="data.producePrintList"
                row-key="pieceId"
                ref="producePrintListRef"
                border
              >
                <el-table-column
                  label="序号"
                  width="60"
                  type="index"
                  align="center"
                />
                <el-table-column
                  label="印刷序列号"
                  min-width="120"
                  prop="printProduceNo"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="书刊编码"
                  min-width="120"
                  prop="bookNo"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="书刊名称"
                  min-width="280"
                  prop="bookName"
                  align="center"
                ></el-table-column>

                <el-table-column
                  label="品种"
                  prop="breed"
                  min-width="160"
                  align="center"
                >
                  <!-- <template #default="scope">
                                        <dict-tag
                                            :options="ems_order_breed_type"
                                            :value="scope.row.breed"
                                        />
                                    </template> -->
                </el-table-column>
                <el-table-column
                  label="白纸裁切"
                  width="160"
                  prop="whitecuttingMachine"
                  align="center"
                >
                  <template #default="scope">
                    <el-button
                      link
                      type="primary"
                      :disabled="flag"
                      @click="
                        handlePrintWorkBranch(
                          scope.row,
                          scope.$index,
                          '5',
                          'whitecuttingMachine'
                        )
                      "
                    >
                      <div>
                        <div
                          v-for="item in scope.row.whitecuttingMachine?.split(
                            '/'
                          )"
                          :key="item"
                        >
                          {{ item }}
                        </div>
                      </div>
                    </el-button>
                  </template>
                </el-table-column>
                <el-table-column
                  label="印刷"
                  width="180"
                  prop="printMachine"
                  align="center"
                >
                  <template #default="scope">
                    <el-button
                      link
                      :disabled="flag"
                      type="primary"
                      @click="
                        handlePrintWorkBranch(
                          scope.row,
                          scope.$index,
                          '2',
                          'printMachine'
                        )
                      "
                    >
                      <div>
                        <div
                          v-for="item in scope.row.printMachine?.split('/')"
                          :key="item"
                        >
                          {{ item }}
                        </div>
                      </div>
                    </el-button>
                  </template>
                </el-table-column>
                <el-table-column
                  label="封面裁切"
                  width="160"
                  prop="covercuttingMachine"
                  align="center"
                >
                  <template #default="scope">
                    <el-button
                      link
                      type="primary"
                      :disabled="flag"
                      @click="
                        handlePrintWorkBranch(
                          scope.row,
                          scope.$index,
                          '6',
                          'covercuttingMachine'
                        )
                      "
                    >
                      <div>
                        <div
                          v-for="item in scope.row.covercuttingMachine?.split(
                            '/'
                          )"
                          :key="item"
                        >
                          {{ item }}
                        </div>
                      </div>
                    </el-button>
                  </template>
                </el-table-column>
                <el-table-column
                  label="覆膜"
                  width="160"
                  prop="coveringMachine"
                  align="center"
                >
                  <template #default="scope">
                    <el-button
                      link
                      :disabled="flag"
                      type="primary"
                      @click="
                        handlePrintWorkBranch(
                          scope.row,
                          scope.$index,
                          '7',
                          'coveringMachine'
                        )
                      "
                    >
                      <div>
                        <div
                          v-for="item in scope.row.coveringMachine?.split('/')"
                          :key="item"
                        >
                          {{ item }}
                        </div>
                      </div>
                      <!-- {{ scope.row.coveringMachine }} -->
                    </el-button>
                  </template>
                </el-table-column>
                <el-table-column
                  label="折页"
                  width="180"
                  prop="foldMachine"
                  align="center"
                >
                  <template #default="scope">
                    <el-button
                      link
                      :disabled="flag"
                      type="primary"
                      @click="
                        handlePrintWorkBranch(
                          scope.row,
                          scope.$index,
                          '4',
                          'foldMachine'
                        )
                      "
                    >
                      <div>
                        <div
                          v-for="item in scope.row.foldMachine?.split('/')"
                          :key="item"
                        >
                          {{ item }}
                        </div>
                      </div>
                      <!-- {{ scope.row.foldMachine }} -->
                    </el-button>
                  </template>
                </el-table-column>
                <el-table-column
                  label="装订"
                  min-width="200"
                  prop="bindingMachine"
                  align="center"
                >
                  <template #default="scope">
                    <el-button
                      link
                      :disabled="flag"
                      type="primary"
                      @click="
                        handlePrintWorkBranch(
                          scope.row,
                          scope.$index,
                          '3',
                          'bindingMachine'
                        )
                      "
                    >
                      <div>
                        <div
                          v-for="item in scope.row.bindingMachine?.split('/')"
                          :key="item"
                        >
                          {{ item }}
                        </div>
                      </div>
                      <!-- {{ scope.row.bindingMachine }} -->
                    </el-button>
                  </template>
                </el-table-column>
                <el-table-column
                  label="组成"
                  min-width="160"
                  prop="composition"
                  align="center"
                >
                  <!-- <template #default="scope">
                                        <dict-tag
                                            :options="ems_order_make_up"
                                            :value="scope.row.composition"
                                        />
                                    </template> -->
                </el-table-column>
                <el-table-column
                  label="印张"
                  width="90"
                  prop="sheet"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="贴标"
                  width="90"
                  prop="labeling"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="印数"
                  width="100"
                  prop="printAmount"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="用纸令数"
                  width="100"
                  prop="reamAmount"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="损耗系数"
                  width="100"
                  prop="lossCoefficient"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="损耗令数"
                  width="120"
                  prop="lossReam"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="用纸总令数"
                  width="100"
                  prop="totalReamAmount"
                  align="center"
                >
                  <!-- <template v-slot="{ row }">
                    <el-input v-model="row.totalReamAmount"> </el-input>
                  </template> -->
                </el-table-column>
                <el-table-column
                  label="吨位系数"
                  width="120"
                  prop="tonnageCoefficient"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="印刷方式"
                  prop="printType"
                  width="100"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="mes_paper_package"
                      :value="scope.row.printType"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="轮转吨数"
                  width="90"
                  prop="rotateTon"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="另行加放"
                  width="120"
                  prop="lxjf"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="成品尺寸"
                  width="120"
                  prop="finishSize"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="ems_produce_finish_size"
                      :value="scope.row.finishSize"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="纸张规格"
                  width="90"
                  prop="paperSpecifications"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="ems_order_print_color"
                      :value="scope.row.printColour"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="下单印数"
                  width="120"
                  prop="orderPrintCount"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="版材尺寸"
                  prop="sheetSize"
                  width="120"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="ems_machine_info_size"
                      :value="scope.row.sheetSize"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="纸型"
                  width="120"
                  prop="paperType"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="mes_paper_type"
                      :value="scope.row.paperType"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="定量"
                  min-width="70"
                  prop="weight"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="幅宽"
                  width="70"
                  prop="clothWidth"
                  align="center"
                ></el-table-column>
                <el-table-column
                  label="品牌"
                  width="120"
                  prop="brand"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="mes_paper_brand"
                      :value="scope.row.brand"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="工艺"
                  min-width="160"
                  prop="technologyId"
                  align="center"
                >
                  <template #default="scope">
                    <el-select
                      clearable
                      style="width: 100%"
                      disabled
                      v-model="scope.row.technologyId"
                      placeholder="请选择工艺"
                    >
                      <el-option
                        v-for="item in technologyList"
                        :key="item.id"
                        :label="item.name"
                        :value="item.id"
                      />
                    </el-select>
                  </template>
                </el-table-column>
                <!-- <el-table-column
                                    label="白纸裁切"
                                    width="120"
                                    prop="whitecuttingMachine"
                                    align="center"
                                    min-width="200"
                                    :show-overflow-tooltip="true"
                                >
                                    <template #default="scope">
                                        <el-button
                                            link
                                            :disabled="flag"
                                            type="primary"
                                            @click="
                                                handlePrintWorkBranch(
                                                    scope.row,
                                                    scope.$index,
                                                    '5',
                                                    'whitecuttingMachine'
                                                )
                                            "
                                        >
                                            {{ scope.row.whitecuttingMachine }}
                                        </el-button>
                                    </template>
                                </el-table-column> -->

                <!-- <el-table-column label="分配机台" width="120" prop="machineName" align="center">
                                </el-table-column>
                                <el-table-column label="分配车间" width="120" prop="workshopName" align="center">
                                </el-table-column> -->
                <!-- <el-table-column
                                    label="操作"
                                    v-if="!route.query.info"
                                    align="center"
                                    fixed="right"
                                    class-name="small-padding fixed-width"
                                >
                                    <template #default="scope">
                                        <el-button
                                            link
                                            type="primary"
                                            @click="handlePrintPoints(scope.row, scope.$index)"
                                            >分配机台</el-button
                                        >
                                    </template>
                                </el-table-column> -->
              </el-table>
            </div>
            <h4>备注</h4>
            <el-input
              v-model="form.remark3"
              disabled
              type="textarea"
              placeholder="请输入内容"
            ></el-input>
          </el-collapse-item>
          <el-collapse-item disabled title="贴数管理" name="6">
            <template #title>
              <el-icon style="color: #4479f6">
                <Position />
              </el-icon>
              <span class="title">贴数管理</span>
            </template>
            <el-table :data="data.producePieceList" border>
              <el-table-column
                label="印刷序列号"
                min-width="120"
                prop="producePieceNo"
                align="center"
              ></el-table-column>
              <el-table-column
                label="品种"
                prop="breed"
                min-width="160"
                align="center"
              >
                <!-- <template #default="scope">
                                    <dict-tag
                                        :options="ems_order_breed_type"
                                        :value="scope.row.breed"
                                    />
                                </template> -->
              </el-table-column>
              <el-table-column
                label="印张"
                width="100"
                prop="sheet"
                align="center"
              ></el-table-column>
              <el-table-column
                label="贴标"
                width="100"
                prop="pieceView"
                align="center"
              ></el-table-column>
              <el-table-column
                label="印刷方式"
                prop="printType"
                min-width="120"
                align="center"
              >
                <template #default="scope">
                  <dict-tag
                    :options="mes_paper_package"
                    :value="scope.row.printType"
                  />
                </template>
              </el-table-column>
              <!-- <el-table-column
                                label="白纸裁切"
                                width="120"
                                prop="whitecuttingMachine"
                                align="center"
                                min-width="200"
                                :show-overflow-tooltip="true"
                            >
                                <template #default="scope">
                                    <el-button
                                        link
                                        type="primary"
                                        :disabled="flag"
                                        @click="
                                            handlePrintWorkBranchPaper(
                                                scope.row,
                                                scope.$index,
                                                '5',
                                                'whitecuttingMachine'
                                            )
                                        "
                                    >
                                        {{ scope.row.whitecuttingMachine }}
                                    </el-button>
                                </template>
                            </el-table-column> -->
              <el-table-column
                label="白纸裁切"
                width="400"
                prop="whitecuttingMachine"
                align="center"
              >
                <template #default="scope">
                  <el-button
                    link
                    :disabled="flag"
                    type="primary"
                    @click="
                      handlePrintWorkBranchPaper(
                        scope.row,
                        scope.$index,
                        '5',
                        'whitecuttingMachine'
                      )
                    "
                  >
                    {{ scope.row.whitecuttingMachine }}
                  </el-button>
                </template>
              </el-table-column>
              <el-table-column
                label="印刷"
                width="180"
                prop="printMachine"
                align="center"
                min-width="200"
                :show-overflow-tooltip="true"
              >
                <template #default="scope">
                  <el-button
                    link
                    type="primary"
                    :disabled="flag"
                    @click="
                      handlePrintWorkBranchPaper(
                        scope.row,
                        scope.$index,
                        '2',
                        'printMachine'
                      )
                    "
                  >
                    <div>
                      <div
                        v-for="item in scope.row.printMachine?.split('/')"
                        :key="item"
                      >
                        {{ item }}
                      </div>
                    </div>
                    <!-- {{ scope.row.printMachine }} -->
                  </el-button>
                </template>
              </el-table-column>
              <el-table-column
                label="封面裁切"
                width="160"
                prop="covercuttingMachine"
                align="center"
                min-width="200"
                :show-overflow-tooltip="true"
              >
                <template #default="scope">
                  <el-button
                    link
                    type="primary"
                    :disabled="flag"
                    @click="
                      handlePrintWorkBranchPaper(
                        scope.row,
                        scope.$index,
                        '6',
                        'covercuttingMachine'
                      )
                    "
                  >
                    <div>
                      <div
                        v-for="item in scope.row.covercuttingMachine?.split(
                          '/'
                        )"
                        :key="item"
                      >
                        {{ item }}
                      </div>
                    </div>
                    <!-- {{ scope.row.covercuttingMachine }} -->
                  </el-button>
                </template>
              </el-table-column>
              <el-table-column
                label="覆膜"
                width="160"
                prop="coveringMachine"
                align="center"
                min-width="200"
                :show-overflow-tooltip="true"
              >
                <template #default="scope">
                  <el-button
                    link
                    type="primary"
                    :disabled="flag"
                    @click="
                      handlePrintWorkBranchPaper(
                        scope.row,
                        scope.$index,
                        '7',
                        'coveringMachine'
                      )
                    "
                  >
                    <div>
                      <div
                        v-for="item in scope.row.coveringMachine?.split('/')"
                        :key="item"
                      >
                        {{ item }}
                      </div>
                    </div>
                    <!-- {{ scope.row.coveringMachine }} -->
                  </el-button>
                </template>
              </el-table-column>
              <el-table-column
                label="折页"
                width="180"
                prop="foldMachine"
                align="center"
                min-width="200"
                :show-overflow-tooltip="true"
              >
                <template #default="scope">
                  <el-button
                    link
                    type="primary"
                    :disabled="flag"
                    @click="
                      handlePrintWorkBranchPaper(
                        scope.row,
                        scope.$index,
                        '4',
                        'foldMachine'
                      )
                    "
                  >
                    <div>
                      <div
                        v-for="item in scope.row.foldMachine?.split('/')"
                        :key="item"
                      >
                        {{ item }}
                      </div>
                    </div>
                    <!-- {{ scope.row.foldMachine }} -->
                  </el-button>
                </template>
              </el-table-column>
              <el-table-column
                label="装订"
                min-width="200"
                prop="bindingMachine"
                align="center"
              >
                <template #default="scope">
                  <el-button
                    link
                    type="primary"
                    :disabled="flag"
                    @click="
                      handlePrintWorkBranchPaper(
                        scope.row,
                        scope.$index,
                        '3',
                        'bindingMachine'
                      )
                    "
                  >
                  <div>
                      <div
                        v-for="item in scope.row.bindingMachine?.split('/')"
                        :key="item"
                      >
                        {{ item }}
                      </div>
                    </div>
                    <!-- {{ scope.row.bindingMachine }} -->
                  </el-button>
                </template>
              </el-table-column>
              <el-table-column
                label="印刷状态"
                v-if="flag"
                width="120"
                prop="pressState"
                align="center"
              >
                <template #default="scope">
                  {{
                    scope.row.pressState == 1
                      ? "未完成"
                      : scope.row.pressState == 2
                      ? "已完成"
                      : ""
                  }}
                </template>
              </el-table-column>
              <el-table-column
                label="覆膜状态"
                v-if="flag"
                width="120"
                prop="coveringState"
                align="center"
              >
                <template #default="scope">
                  {{
                    scope.row.coveringState == 1
                      ? "未完成"
                      : scope.row.coveringState == 2
                      ? "已完成"
                      : ""
                  }}
                </template>
              </el-table-column>
              <el-table-column
                label="裁切状态"
                v-if="flag"
                width="120"
                prop="trimmingState"
                align="center"
              >
                <template #default="scope">
                  {{
                    scope.row.trimmingState == 1
                      ? "未完成"
                      : scope.row.trimmingState == 2
                      ? "已完成"
                      : ""
                  }}
                </template>
              </el-table-column>
              <el-table-column
                label="折页状态"
                v-if="flag"
                width="120"
                prop="foldState"
                align="center"
              >
                <template #default="scope">
                  {{
                    scope.row.foldState == 1
                      ? "未完成"
                      : scope.row.foldState == 2
                      ? "已完成"
                      : ""
                  }}
                </template>
              </el-table-column>
              <el-table-column
                label="装订状态"
                v-if="flag"
                width="120"
                prop="pressState"
                align="center"
              >
                <template #default="scope">
                  {{
                    scope.row.bindingState == 1
                      ? "未完成"
                      : scope.row.bindingState == 2
                      ? "已完成"
                      : ""
                  }}
                </template>
              </el-table-column>
              <!-- <el-table-column
                                label="分配机台"
                                width="120"
                                prop="machineName"
                                align="center"
                            >
                            </el-table-column>
                            <el-table-column
                                label="分配车间"
                                width="120"
                                prop="workshopName"
                                align="center"
                            >
                            </el-table-column>
                            <el-table-column
                                label="操作"
                                v-if="!route.query.info"
                                align="center"
                                fixed="right"
                                class-name="small-padding fixed-width"
                            >
                                <template #default="scope">
                                    <el-button
                                        link
                                        type="primary"
                                        @click="handlePiecePoints(scope.row, scope.$index)"
                                        >分配机台11</el-button
                                    >
                                </template>
                            </el-table-column> -->
            </el-table>

            <h4>备注</h4>
            <el-input
              v-model="form.remark4"
              disabled
              type="textarea"
              placeholder="请输入内容"
            ></el-input>
          </el-collapse-item>
        </div>
      </el-collapse>
    </el-card>
    <SearchWorkBench
      :visible="searchVisible"
      @changeUpdate="changeWorkBenchData"
      :machineType="machineType"
      :search="{ workshopId }"
      @cancel="
        () => {
          workshopId = undefined;
          searchVisible = false;
        }
      "
    ></SearchWorkBench>
  </div>
</template>

<script setup>
// 订单内容选过一次不能再选
import useTagsViewStore from "@/store/modules/tagsView";
import {
  addProduceOrderList,
  getProduceById,
  updateProducePieceMachine,
} from "@/api/production/cover";
import SearchWorkBench from "@/components/SearchWorkBench";
import { getTechnologyList } from "@/api/production/technics.js";
import { ElMessage } from "element-plus";
const tagsViewStore = useTagsViewStore();
const { proxy } = getCurrentInstance();
const {
  ems_produce_new_past,
  ems_machine_info_size,
  ems_produce_hykb,
  mes_paper_material,
  mes_paper_specs,
  ems_produce_package_require,
  mes_paper_unit,
  ems_produce_print_colour_type,
  ems_produce_color,
  ems_produce_is_new,
  mes_paper_type,
  ems_workshop_subject_type,
  ems_order_make_up,
  ems_order_breed_type,
  ems_order_print_color,
  ems_produce_paper_size,
  ems_produce_cover_film,
  ems_produce_marking,
  ems_order_binding_mode,
  ems_produce_finish_size,
  ems_produce_book_size,
  mes_paper_brand,
  mes_paper_package,
  ems_order_make_up_fm,
  ems_workshop,
} = proxy.useDict(
  "ems_produce_new_past",
  "ems_produce_book_size",
  "mes_paper_brand",
  "mes_paper_package",
  "ems_order_binding_mode",
  "ems_produce_finish_size",
  "mes_paper_unit",
  "ems_produce_package_require",
  "mes_paper_specs",
  "mes_paper_material",
  "ems_produce_hykb",
  "ems_machine_info_size",
  "ems_produce_color",
  "ems_produce_print_colour_type",
  "ems_produce_is_new",
  "ems_produce_paper_size",
  "ems_produce_cover_film",
  "ems_produce_marking",
  "mes_paper_type",
  "ems_order_print_color",
  "ems_order_make_up",
  "ems_workshop_subject_type",
  "ems_order_breed_type",
  "ems_order_make_up_fm",
  "ems_workshop"
);

const route = useRoute();
const router = useRouter();
const activeNames = ["1", "2", "3", "4", "5", "6"];
const userRef = ref(null);
const selectPrint = ref({});
const listBPT = ref([]);
const orderNo = ref("");
const currentIndexJT = ref(0);
const workshopId = ref(null);
const currentIndexTS = ref(0);
const machineNameList = ref([]);
const workshopNameList = ref([]);
const flag = ref(false);
const searchVisible = ref(false);
const stateIndex = ref(undefined);
const machineType = ref("");
const selectName = ref("");
const technologyList = ref([]);
const data = reactive({
  produceProductList: [], // 产品
  producePaperList: [], // 纸张
  producePrintList: [], // 印刷
  produceCoveringList: [], // 覆膜
  producePieceList: [],
  machineNameList: [],
  workshopNameList: [],
  form: {
    isNew: "1",
    type: "1",
  },
  rules: {
    // machineName: [{ required: true, message: "机台不能为空", trigger: ["blur",] },],
  },
});

const {
  form,
  rules,
  produceProductList,
  producePaperList,
  producePrintList,
  produceCoveringList,
  producePieceList,
} = toRefs(data);
const getList = () => {
  getProduceById({ pid: route.query.id }).then((res) => {
    Object.assign(form.value, { ...res.data });
    produceProductList.value = res.data.produceProductList;
    producePrintList.value = res.data.producePrintList;
    producePaperList.value = res.data.producePaperList;
    produceCoveringList.value = res.data.produceCoveringList;
    producePieceList.value = res.data.producePieceList;
    if (res.data.type == 2) {
      if (res.data.irregularBooks) {
        const resp = JSON.parse(res.data.irregularBooks);
        listBPT.value = resp.listBPT;
        orderNo.value = resp.bookCode;
      }
      machineNameList.value = sumMachineNameList(res.data.producePieceList);
      workshopNameList.value = sumWorkshopNameList(res.data.producePieceList);
      producePieceList.value.forEach((item) => {
        producePrintList.value.forEach((obj) => {
          obj.machineName = "";
          obj.workshopName = "";
          if (item.printId === obj.printId) {
            item.producePieceNo = obj.printProduceNo;
          }
        });
      });
      machineNameTotal(producePrintList.value, producePieceList.value);
      workshopNameTotal(producePrintList.value, producePieceList.value);
    } else if (res.data.type == 1) {
      // 封面
      machineNameList.value = sumMachineNameList(res.data.producePrintList);
      workshopNameList.value = sumWorkshopNameList(res.data.producePrintList);
    }
    if (route.query.info) {
      flag.value = true;
    }
  });
};
if (route.query?.id) {
  getList();
}

function machineNameTotal(list, arr) {
  for (let i = 0; i < arr.length; i++) {
    let matchingIndex = list.findIndex(
      (item) => item.printId === arr[i].printId
    );
    if (matchingIndex !== -1) {
      if (!list[matchingIndex].machineName.includes(arr[i].machineName)) {
        list[matchingIndex].machineName += arr[i].machineName + " ";
      }
    } else {
      list.push(arr[i]);
    }
  }
}
//  获取工艺
const getTechnologyArr = () => {
  getTechnologyList({ pageNum: 1, pageSize: 100 }).then((res) => {
    technologyList.value = res.rows;
  });
};
getTechnologyArr();
function workshopNameTotal(list, arr) {
  for (let i = 0; i < arr.length; i++) {
    let matchingIndex = list.findIndex(
      (item) => item.printId === arr[i].printId
    );
    if (matchingIndex !== -1) {
      if (!list[matchingIndex].workshopName.includes(arr[i].workshopName)) {
        list[matchingIndex].workshopName += arr[i].workshopName + " ";
      }
    } else {
      list.push(arr[i]);
    }
  }
}

// 机台汇总
function sumMachineNameList(list) {
  let uniqueNamesById = {};
  list.forEach((item) => {
    uniqueNamesById[item.machineName] = item.machineName;
  });
  return Object.values(uniqueNamesById);
}
// 车间汇总
function sumWorkshopNameList(list) {
  let uniqueNamesById = {};
  list.forEach((item) => {
    uniqueNamesById[item.workshopName] = item.workshopName;
  });

  return Object.values(uniqueNamesById);
}
//  返回
// const goBack = () => {
//   router.replace({ path: "/production/allocation" });
//   setTimeout(() => {
//     tagsViewStore.delView(route);
//   }, 0);
// };

//  返回
const goBack = () => {
  tagsViewStore.delView(route);
  router.go(-1);
};

// 选中的机台
const changeWorkBenchData = (row) => {
  if (stateIndex.value == "2") {
    // if (form.value.type == '2') {
    //     producePieceList.value.forEach((obj) => {
    //         if (selectPrint.value.printId === obj.printId) {
    //             obj.machineName = row.machineName
    //             obj.machineId = row.machineId
    //             obj.workshopName = row.workshopName
    //         }
    //     })
    // }
    updateProducePieceMachine({
      printId: selectPrint.value.printId,
      machineId: row.pid,
      machineType: machineType.value,
    }).then((res) => {
      getList();
    });
    producePrintList.value[currentIndexJT.value][selectName.value] =
      row.machineName;
    producePrintList.value[currentIndexJT.value].machineId = row.machineId;
    // producePrintList.value[currentIndexJT.value].workshopName = row.workshopName
  } else {
    updateProducePieceMachine({
      pieceId: selectPrint.value.pieceId,
      printId: selectPrint.value.printId,
      machineId: row.pid,
      machineType: machineType.value,
    }).then((res) => {
      getList();
    });
    producePieceList.value[currentIndexTS.value][selectName.value] =
      row.machineName;
    producePieceList.value[currentIndexTS.value].machineId = row.machineId;
    // producePieceList.value[currentIndexTS.value].workshopName = row.workshopName
  }
  searchVisible.value = false;
};
const handlePrintWorkBranch = (row, index, type, name) => {
  //  type 机器类型
  selectName.value = name;
  machineType.value = type;
  selectPrint.value = row;
  searchVisible.value = true;
  //  state 2 印刷管理 state 3 贴数管理
  currentIndexJT.value = index;
  stateIndex.value = "2";
  if (type == 2) {
    workshopId.value = form.value.workshopId;
  } else {
    workshopId.value = undefined;
  }
};
const handlePrintWorkBranchPaper = (row, index, type, name) => {
  //  type 机器类型
  selectName.value = name;
  machineType.value = type;
  selectPrint.value = row;
  searchVisible.value = true;
  //  state 2 印刷管理 state 3 贴数管理
  currentIndexJT.value = index;
  stateIndex.value = "3";
  if (type == 2) {
    workshopId.value = form.value.workshopId;
  } else {
    workshopId.value = undefined;
  }
};

// 分配机台 印刷
const handlePrintPoints = (row, index) => {
  selectPrint.value = row;
  searchVisible.value = true;
  //  state 2 印刷管理 state 3 贴数管理
  currentIndexJT.value = index;
  stateIndex.value = "2";
};
// 分配机台 贴数
const handlePiecePoints = (row, index) => {
  searchVisible.value = true;
  //  state 2 印刷管理 state 3 贴数管理
  currentIndexTS.value = index;
  stateIndex.value = "3";
};
const submitForm = async () => {
  try {
    await userRef.value.validate();
    form.value.processStatus = 2; // 已经审核
    // form.value.status = 20 // 分配审核
    await addProduceOrderList({
      ...form.value,
      produceProductList: produceProductList.value,
      producePaperList: producePaperList.value,
      producePrintList: producePrintList.value,
      produceCoveringList: produceCoveringList.value,
    });
    ElMessage({
      message: "审核成功",
      type: "success",
    });
    goBack();
  } catch (error) {
    // if (Object.values(error)[0][0]?.message) {
    //     ElMessage({
    //         message: '请将内容填写完整',
    //         type: 'warning'
    //     });
    // }
  }
};
</script>

<style lang="scss" scoped>
.footer {
  text-align: center;
}

:deep(.el-pagination) {
  position: unset;
}

.order-form :deep(.el-form-item) {
  margin-bottom: 0px;
}

:deep(.el-table th.must div:before) {
  content: "*";
  color: #ff1818;
}

:deep(.el-table) .success-row {
  background: #dae5f4 !important;
}

.text {
  font-weight: 600;
  color: #666262;
}

table,
th,
td {
  border: 1px solid #ccc;
}

th,
td {
  padding: 8px;
  text-align: center;
}

th {
  background-color: #f2f2f2;
}
</style>
